<?php 
session_start();
include_once '../config.php';
header("Content-type: application/json");
list($usrID,$channelID,$lastID)=array(intval($_SESSION['usrID']),intval($_GET['channelID']),intval($_POST['lastID']));
$res=$pdo->query("select g.chatID,g.msg,if(g.usrID=$usrID,'Me',concat(u.lname,' ',u.fname)) as name from (gchat g join usr u on u.usrID) where u.usrID=g.usrID and g.usrID != $usrID and g.channelID=$channelID and g.chatID > $lastID");//unix_timestamp()// and c.seen=0
echo json_encode($res->fetchAll(PDO::FETCH_ASSOC));
?>